{extend name='admin@public/content'}
{block name="button"}
{if auth("$classuri/create")}
<button data-open='{:url("$classuri/create")}' data-title="创建" class='layui-btn layui-btn-sm layui-btn-primary'>新建插件</button>
{/if}
{/block}

{block name="content"}
<form onsubmit="return false;" data-auto="true" method="post">
	{empty name='list'}
	<p class="help-block text-center well">没 有 记 录 哦！</p>
	{else}
	<!-- 数据列表 -->
	<table class="layui-table" lay-skin="line">
		<thead>
			<tr>
				<th width="80px">名称</th>
				<th width="50px">标识</th>
				<th width="200px">描述</th>
				<th width="50px">状态</th>
				<th width="43px">作者</th>
				<th width="43px">版本</th>
				<th width="100px">操作</th>
			</tr>
		</thead>
		<tbody>
			{notempty name="list"}
			{volist name="list" id="vo"}
			<tr>
				<td>{$vo.title}</td>
				<td>{$vo.name}</td>
				<td>{$vo.description}</td>
				<?php $addons_hook = addons_hook($vo['name']); ?>
				<td>{$vo.status_text|default="未安装"}</td>
				<td class="text-success"><a target="_blank" href="{$vo.url|default='http://www.diygw.com'}">{$vo.author}</a></td>
				<td>{$vo.version}</td>
				<td>
					{eq name="vo.uninstall" value="0"}
						<?php
							$class	= get_addon_class($vo['name']);
							if(!class_exists($class)){
								$has_config = 0;
							}else{
								$addon = new $class();
								$has_config = count($addon->getConfig());
							}
						?>
						<?php if ($has_config): ?>
							<a data-open="{:url('config',array('id'=>$vo['id']))}" title="设置">设置</a>
						<?php endif; ?>
					<?php if ($vo['status'] >=0): ?>
						{eq name="vo.status" value="0"}
							<a data-update="{$vo.id}"  data-action='{:url("enable")}' title="启用">启用</a>
						{else /}
							<a data-update="{$vo.id}"  data-action='{:url("disable")}' title="禁用">禁用</a>
						{/eq}
					<?php endif; ?>
					{else/}
						<a data-load='{:url('install?addon_name='.$vo['name'])}' title="安装">安装</a>
					{/eq}
				</td>
			</tr>
			{/volist}
			{else/}
			<td colspan="6" class="text-center"> aOh! 暂时还没有内容! </td>
			{/notempty}
		</tbody>
	</table>
	<!-- 分页 -->
	{if isset($page)}<p>{$page|raw}</p>{/if}
	{/empty}
</form>
{/block}

